<template>
	<view class="add-repair-container">
		<!-- 使用系统导航栏，移除自定义头部 -->
		
		<!-- 表单内容 -->
		<view class="form-container">
		<!-- 基本信息 -->
			<view class="form-section">
				<view class="section-header">
					<text class="section-title">基本信息</text>
				</view>
				
				<view class="form-item">
					<text class="form-label">资产编号 <text class="required">*</text></text>
					<view class="asset-select-wrapper" @click="selectAsset">
						<text class="asset-select-text" :class="{ placeholder: !formData.assetNo }">
							{{ formData.assetNo || '请选择' }}
						</text>
						<button class="select-asset-btn">选择资产</button>
					</view>
				</view>
				
				<view class="form-item" v-if="formData.assetNo">
					<text class="form-label">类型</text>
					<text class="form-value">{{ formData.assetTypeName || '-' }}</text>
				</view>
				
				<view class="form-item" v-if="formData.assetNo">
					<text class="form-label">名称</text>
					<text class="form-value">{{ formData.assetName || '-' }}</text>
				</view>
				
				<view class="form-item" v-if="formData.assetNo">
					<text class="form-label">位置</text>
					<text class="form-value">{{ formData.location || '-' }}</text>
				</view>
				
				<view class="form-item" v-if="formData.assetNo">
					<text class="form-label">使用部门</text>
					<text class="form-value">{{ formData.deptName || '-' }}</text>
				</view>
			</view>
			
			<!-- 故障信息 -->
			<view class="form-section">
				<view class="section-header">
					<text class="section-title">故障信息</text>
				</view>
				
				<view class="form-item">
					<text class="form-label">发生时间 <text class="required">*</text></text>
                    <picker mode="multiSelector" :range="timeRange" :value="timeValue" @change="onTimeChange">
						<view class="picker-input">
                            <text class="picker-text">{{ formData.occurTime || '请选择' }}</text>
							<text class="picker-arrow">></text>
						</view>
					</picker>
				</view>
				
			<view class="form-item">
				<text class="form-label">报修人 <text class="required">*</text></text>
				<view class="picker-input disabled">
					<text class="picker-text">{{ formData.reporter || '当前用户' }}</text>
				</view>
			</view>
				
				<view class="form-item">
					<text class="form-label">报修类型 <text class="required">*</text></text>
					<picker :range="reportTypeOptions" range-key="name" @change="onReportTypeChange">
						<view class="picker-input">
							<text class="picker-text">{{ formData.reportTypeName || '请选择' }}</text>
							<text class="picker-arrow">></text>
						</view>
					</picker>
				</view>
				
				<view class="form-item">
					<text class="form-label">故障类型 <text class="required">*</text></text>
					<picker :range="faultTypeOptions" range-key="name" @change="onFaultTypeChange">
						<view class="picker-input">
							<text class="picker-text">{{ formData.faultTypeName || '请选择' }}</text>
							<text class="picker-arrow">></text>
						</view>
					</picker>
				</view>
				
				<view class="form-item">
					<text class="form-label">紧急程度 <text class="required">*</text></text>
					<picker :range="urgencyOptions" range-key="name" @change="onUrgencyChange">
						<view class="picker-input">
							<text class="picker-text">{{ formData.urgencyName || '请选择' }}</text>
							<text class="picker-arrow">></text>
						</view>
					</picker>
				</view>
				
				<!-- 故障图片 -->
				<view class="form-item form-item-column">
					<text class="form-label">故障图片</text>
					<view class="image-upload-section">
						<view class="upload-header" @click="chooseImage">
							<text class="upload-icon">📎</text>
							<text class="upload-text">添加附件</text>
							<text class="image-count">({{ formData.imageUrls.length }}/9)</text>
						</view>
						<view class="image-preview-list" v-if="formData.imageUrls.length > 0">
							<view class="preview-item" v-for="(image, index) in formData.imageUrls" :key="index">
								<image class="preview-img" :src="getImageUrl(image)" mode="aspectFill" @click="previewImage(index)"></image>
								<view class="delete-btn" @click.stop="deleteImage(index)">
									<text class="delete-icon">×</text>
								</view>
							</view>
						</view>
					</view>
				</view>
				
				<!-- 故障描述 -->
				<view class="form-item">
					<text class="form-label">故障描述 <text class="required">(必填项)</text></text>
					<textarea 
						class="form-textarea" 
						v-model="formData.faultDescription" 
						placeholder="请输入"
						maxlength="500"
					></textarea>
				</view>
			</view>
		</view>
		
		<!-- 底部按钮 -->
		<view class="bottom-actions">
			<button class="action-button submit-full" @click="submitForm">保存草稿</button>
		</view>
		
		<!-- 资产选择弹窗 -->
		<view class="asset-modal" v-if="showAssetModal" @click="closeAssetModal">
			<view class="modal-content" @click.stop>
				<view class="modal-header">
					<text class="modal-title">选择资产</text>
					<text class="modal-close" @click="closeAssetModal">×</text>
				</view>
				
				<view class="modal-search">
					<input class="search-input" v-model="assetSearchKey" placeholder="搜索资产编号或名称" @input="searchAssets" />
				</view>
				
				<view class="modal-body">
					<view class="asset-list">
						<view 
							class="asset-item" 
							v-for="asset in assetList" 
							:key="asset.assetNo"
							@click="selectAssetItem(asset)"
						>
							<view class="asset-info">
								<text class="asset-no">{{ asset.assetNo }}</text>
								<text class="asset-name">{{ asset.assetName || asset.name }}</text>
							</view>
							<view class="asset-detail">
								<text class="asset-location">{{ asset.location }}</text>
								<text class="asset-type">{{ asset.equipmentTypeName }}</text>
							</view>
						</view>
					</view>
					
					<view class="empty-data" v-if="assetList.length === 0">
						<text class="empty-text">暂无资产数据</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
    import { addFaultReport, submitFaultReport, checkUnfinishedReport, uploadFaultImage, listFaultReport } from '@/api/repair/faultReport.js';
	import assetApi from '@/api/asset/asset.js';
	import { listReportType } from '@/api/dict/reportType.js';
	import { listFaultType } from '@/api/dict/faultType.js';
	import { listLevel } from '@/api/dict/level.js';
	
	export default {
		data() {
			return {
				formData: {
					assetNo: '',
					assetType: '',
					assetTypeName: '',
					assetName: '',
					location: '',
					deptName: '',
					occurTime: '',
					reporter: '',
					reportType: '',
					reportTypeName: '',
					faultType: '',
					faultTypeName: '',
					urgency: '',
					urgencyName: '',
					faultDescription: '',
					imageUrls: [], // 存储已上传的文件名
					status: 'DRAFT' // 初始状态为草稿
				},
				// 选择器索引
				reportTypeIndex: 0,
				faultTypeIndex: 0,
				urgencyIndex: 0,
				// 时间选择器
				timeValue: [0, 0, 0, 0, 0],
				timeRange: [[], [], [], [], []],
				// 选项数据（从后端字典加载）
				reportTypeOptions: [],
				faultTypeOptions: [],
				urgencyOptions: [],
				// 资产选择
				showAssetModal: false,
				assetList: [],
				assetSearchKey: ''
			}
		},
		onLoad() {
			this.initTimePicker();
			this.loadDictionaryData();
			this.loadUserInfo();
		},
		methods: {
			// 获取图片URL
			getImageUrl(fileName) {
				if (!fileName) return '';
				// 如果已经是完整URL，直接返回
				if (/^https?:\/\//i.test(fileName)) return fileName;
				// 否则拼接MinIO URL
				const minioBase = uni.getStorageSync('MINIO_BASE') || 'https://io.brightholdings.cn';
				const bucket = 'smart-maintenance';
				return `${minioBase.replace(/\/$/, '')}/${bucket}/${fileName}`;
			},
			
			// 初始化时间选择器
			initTimePicker() {
				const now = new Date();
				const year = now.getFullYear();
				const month = now.getMonth();
				const day = now.getDate();
				const hour = now.getHours();
				const minute = now.getMinutes();
				
				// 生成年份选项
				const years = [];
				for (let i = year - 1; i <= year + 1; i++) {
					years.push(i + '年');
				}
				
				// 生成月份选项
				const months = [];
				for (let i = 1; i <= 12; i++) {
					months.push(i + '月');
				}
				
				// 生成日期选项
				const days = [];
				for (let i = 1; i <= 31; i++) {
					days.push(i + '日');
				}
				
				// 生成小时选项
				const hours = [];
				for (let i = 0; i < 24; i++) {
					hours.push(i + '时');
				}
				
				// 生成分钟选项
				const minutes = [];
				for (let i = 0; i < 60; i += 5) {
					minutes.push(i + '分');
				}
				
                this.timeRange = [years, months, days, hours, minutes];
                // 默认滚动定位到当前时间，方便用户选择，但不赋默认值
                this.timeValue = [1, month, day - 1, hour, Math.floor(minute / 5)];
			},
			
			// 格式化日期时间
			formatDateTime(date) {
				const year = date.getFullYear();
				const month = String(date.getMonth() + 1).padStart(2, '0');
				const day = String(date.getDate()).padStart(2, '0');
				const hour = String(date.getHours()).padStart(2, '0');
				const minute = String(date.getMinutes()).padStart(2, '0');
				const second = String(date.getSeconds()).padStart(2, '0');
				return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
			},
			
			// 加载字典数据
			async loadDictionaryData() {
				try {
					// 加载报修类型
					const reportTypeRes = await listReportType({ pageNum: 1, pageSize: 9999 });
					if (reportTypeRes && reportTypeRes.rows) {
						this.reportTypeOptions = reportTypeRes.rows
							.filter(item => item.enabled === 1 || item.enabled === '1' || item.enabled === true)
							.map(item => ({
								code: item.code,
								name: item.name
							}));
					}
					
					// 加载故障类型
					const faultTypeRes = await listFaultType({ pageNum: 1, pageSize: 9999 });
					if (faultTypeRes && faultTypeRes.rows) {
						this.faultTypeOptions = faultTypeRes.rows
							.filter(item => item.enabled === 1 || item.enabled === '1' || item.enabled === true)
							.map(item => ({
								code: item.code,
								name: item.name
							}));
					}
					
					// 加载紧急程度
					const levelRes = await listLevel({ pageNum: 1, pageSize: 9999 });
					if (levelRes && levelRes.rows) {
						this.urgencyOptions = levelRes.rows
							.filter(item => item.enabled === 1 || item.enabled === '1' || item.enabled === true)
							.map(item => ({
								code: item.code,
								name: item.name,
								color: item.color || '#409EFF'
							}));
					}
				} catch (error) {
					console.error('加载字典数据失败:', error);
					
					// 获取错误信息
					const errorMsg = error.message || error.msg || '加载选项失败';
					
					// 使用模态框显示错误信息
					uni.showModal({
						title: '加载失败',
						content: errorMsg + '\n\n请稍后重试或联系管理员',
						showCancel: false,
						confirmText: '知道了'
					});
				}
			},
			
			// 时间选择器变化
			onTimeChange(e) {
				this.timeValue = e.detail.value;
				const [yearIndex, monthIndex, dayIndex, hourIndex, minuteIndex] = e.detail.value;
				
				const year = parseInt(this.timeRange[0][yearIndex]);
				const month = parseInt(this.timeRange[1][monthIndex]);
				const day = parseInt(this.timeRange[2][dayIndex]);
				const hour = parseInt(this.timeRange[3][hourIndex]);
				const minute = parseInt(this.timeRange[4][minuteIndex]);
				
				const date = new Date(year, month - 1, day, hour, minute);
				this.formData.occurTime = this.formatDateTime(date);
			},
			
			// 报修类型选择
			onReportTypeChange(e) {
				this.reportTypeIndex = e.detail.value;
				const selected = this.reportTypeOptions[e.detail.value];
				this.formData.reportType = selected.code;
				this.formData.reportTypeName = selected.name;
			},
			
			// 故障类型选择
			onFaultTypeChange(e) {
				this.faultTypeIndex = e.detail.value;
				const selected = this.faultTypeOptions[e.detail.value];
				this.formData.faultType = selected.code;
				this.formData.faultTypeName = selected.name;
			},
			
			// 紧急程度选择
			onUrgencyChange(e) {
				this.urgencyIndex = e.detail.value;
				const selected = this.urgencyOptions[e.detail.value];
				this.formData.urgency = selected.code;
				this.formData.urgencyName = selected.name;
			},
			
			// 选择图片并上传
			chooseImage() {
				const maxCount = 9 - this.formData.imageUrls.length;
				if (maxCount <= 0) {
					uni.showToast({
						title: '最多上传9张图片',
						icon: 'none'
					});
					return;
				}
				
				uni.chooseImage({
					count: maxCount,
					sizeType: ['compressed'],
					sourceType: ['album', 'camera'],
					success: async (res) => {
						const files = res.tempFilePaths || [];
						if (files.length === 0) return;
						
						uni.showLoading({
							title: '上传中...',
							mask: true
						});
						
						let successCount = 0;
						let failCount = 0;
						
						for (const filePath of files) {
							try {
								// 上传图片到MinIO，获取文件名
								const fileName = await uploadFaultImage(filePath);
								if (fileName) {
									this.formData.imageUrls.push(String(fileName));
									successCount++;
									console.log('图片上传成功:', fileName);
								} else {
									failCount++;
								}
							} catch (error) {
								failCount++;
								console.error('图片上传失败:', error);
							}
						}
						
						uni.hideLoading();
						
						if (successCount > 0) {
							uni.showToast({
								title: `成功上传${successCount}张图片`,
								icon: 'success'
							});
						}
						
						if (failCount > 0) {
							uni.showToast({
								title: `${failCount}张图片上传失败`,
								icon: 'none'
							});
						}
					}
				});
			},
			
			// 预览图片
			previewImage(index) {
				// 转换所有图片为完整URL
				const urls = this.formData.imageUrls.map(fileName => this.getImageUrl(fileName));
				uni.previewImage({
					urls: urls,
					current: index
				});
			},
			
			// 删除图片
			deleteImage(index) {
				uni.showModal({
					title: '确认删除',
					content: '确定要删除这张图片吗？',
					success: (res) => {
						if (res.confirm) {
							this.formData.imageUrls.splice(index, 1);
							uni.showToast({
								title: '删除成功',
								icon: 'success'
							});
						}
					}
				});
			},
			
			// 选择资产
			selectAsset() {
				this.showAssetModal = true;
				this.loadAssetList();
			},
			
			// 关闭资产选择弹窗
			closeAssetModal() {
				this.showAssetModal = false;
				this.assetSearchKey = '';
			},
			
			// 加载资产列表
			async loadAssetList() {
				try {
					uni.showLoading({ title: '加载中...' });
					const res = await assetApi.listAsset({
						pageNum: 1,
						pageSize: 100
					});
					
					if (res && res.code === 200) {
						this.assetList = res.rows || [];
					}
					uni.hideLoading();
				} catch (error) {
					uni.hideLoading();
					console.error('加载资产列表失败:', error);
					
					// 获取错误信息
					const errorMsg = error.message || error.msg || '加载资产列表失败';
					
					// 使用模态框显示错误信息
					uni.showModal({
						title: '加载失败',
						content: errorMsg + '\n\n请稍后重试',
						showCancel: false,
						confirmText: '知道了'
					});
				}
			},
			
			// 搜索资产
			async searchAssets(e) {
				const keyword = e.detail.value;
				if (!keyword) {
					this.loadAssetList();
					return;
				}
				
				try {
					const res = await assetApi.listAsset({
						pageNum: 1,
						pageSize: 100,
						assetNo: keyword,
						name: keyword
					});
					
					if (res && res.code === 200) {
						this.assetList = res.rows || [];
					}
				} catch (error) {
					console.error('搜索资产失败:', error);
				}
			},
			
		// 选择资产项
		async selectAssetItem(asset) {
			try {
				uni.showLoading({ title: '检查中...' });
				
			// 检查资产是否有未完成的报修
			const checkRes = await checkUnfinishedReport(asset.assetNo);
				uni.hideLoading();
				
				if (checkRes && checkRes.code === 200) {
					const hasUnfinished = checkRes.data;
					
					if (hasUnfinished) {
						// 资产有未完成的报修，显示提示并阻止选择
						uni.showModal({
							title: '无法选择',
							content: '该设备已有未完成的报修，不可重复添加报修。\n\n请选择其他设备或等待当前报修完成。',
							showCancel: false,
							confirmText: '知道了'
						});
						return;
					}
				}
				
				// 没有未完成的报修，允许选择
				this.formData.assetNo = asset.assetNo;
				this.formData.assetType = asset.equipmentTypeCode;
				this.formData.assetTypeName = asset.equipmentTypeName || '设备';
				this.formData.assetName = asset.assetName || asset.name;
				this.formData.location = asset.location;
				this.formData.deptName = asset.deptName;
				
				this.closeAssetModal();
				
				uni.showToast({
					title: '资产已选择',
					icon: 'success'
				});
			} catch (error) {
				uni.hideLoading();
				console.error('检查资产报修状态失败:', error);
				
				// 如果检查失败，询问是否继续
				uni.showModal({
					title: '提示',
					content: '无法检查资产报修状态，是否继续选择？',
					success: (res) => {
						if (res.confirm) {
							this.formData.assetNo = asset.assetNo;
							this.formData.assetType = asset.equipmentTypeCode;
							this.formData.assetTypeName = asset.equipmentTypeName || '设备';
							this.formData.assetName = asset.assetName || asset.name;
							this.formData.location = asset.location;
							this.formData.deptName = asset.deptName;
							
							this.closeAssetModal();
							
							uni.showToast({
								title: '资产已选择',
								icon: 'success'
							});
						}
					}
				});
			}
		},
			
			// 表单验证
			validateForm() {
				if (!this.formData.assetNo) {
					uni.showToast({
						title: '请选择资产',
						icon: 'none'
					});
					return false;
				}
				
				if (!this.formData.occurTime) {
					uni.showToast({
						title: '请选择发生时间',
						icon: 'none'
					});
					return false;
				}
				
				if (!this.formData.reporter) {
					uni.showToast({
						title: '请选择报修人',
						icon: 'none'
					});
					return false;
				}
				
				if (!this.formData.reportType) {
					uni.showToast({
						title: '请选择报修类型',
						icon: 'none'
					});
					return false;
				}
				
				if (!this.formData.faultType) {
					uni.showToast({
						title: '请选择故障类型',
						icon: 'none'
					});
					return false;
				}
				
				if (!this.formData.urgency) {
					uni.showToast({
						title: '请选择紧急程度',
						icon: 'none'
					});
					return false;
				}
				
				if (!this.formData.faultDescription.trim()) {
					uni.showToast({
						title: '请输入故障描述',
						icon: 'none'
					});
					return false;
				}
				
				return true;
			},
			
			// 加载用户信息
			loadUserInfo() {
				try {
					const userInfo = uni.getStorageSync('userInfo');
					if (userInfo) {
						// 用户信息结构：userInfo.user.userName 或 userInfo.user.nickName
						if (userInfo.user) {
							this.formData.reporter = userInfo.user.nickName || userInfo.user.userName || 'admin';
						} else {
							// 兼容旧版本的用户信息结构
							this.formData.reporter = userInfo.userName || userInfo.nickName || userInfo.name || 'admin';
						}
					} else {
						// 如果没有用户信息，尝试从其他存储位置获取
						const username = uni.getStorageSync('username');
						this.formData.reporter = username || 'admin';
					}
				} catch (e) {
					console.error('加载用户信息失败:', e);
					this.formData.reporter = 'admin'; // 出错时使用默认值
				}
			},
			
			// 提交表单
			async submitForm() {
				if (!this.validateForm()) {
					return;
				}
                // 提交前校验：是否存在未完成的报修
                if (this.formData.assetNo) {
                    try {
                        const chk = await checkUnfinishedReport(this.formData.assetNo)
                        if (chk && chk.code === 200 && chk.data && chk.data.hasUnfinished) {
                            uni.showModal({
                                title: '提示',
                                content: '该资产存在未完成的报修，确认仍要提交吗？',
                                success: async (res) => {
                                    if (res.confirm) {
                                        await this.doSubmit()
                                    }
                                }
                            })
                            return
                        }
                    } catch (e) {
                        // 忽略检查异常，不阻断提交
                    }
                }
                await this.doSubmit()
            },

            async doSubmit() {
				uni.showLoading({
					title: '保存中...'
				});
				
				try {
					// 准备提交数据
					const submitData = {
						...this.formData,
						// 将imageUrls数组转为JSON字符串
						imageUrls: JSON.stringify(this.formData.imageUrls || []),
						// 状态为草稿（后端会自动生成报修单号）
						status: 'DRAFT'
					};
					
					// 调用API新增故障报修（保存为草稿）
					const addResult = await addFaultReport(submitData);
					console.log('保存草稿返回:', addResult);
					
					if (addResult.code === 200 || addResult.code === '200') {
						uni.hideLoading();
						uni.showToast({
							title: '报修草稿已保存',
							icon: 'success'
						});
						
						// 设置刷新标记
						uni.setStorageSync('needRefreshDrafts', true);
						
						// 返回上一页
						setTimeout(() => {
							uni.navigateBack();
						}, 1500);
					} else {
						throw new Error(addResult.msg || '保存失败');
					}
					
				} catch (error) {
					uni.hideLoading();
					
					// 获取错误信息
					const errorMsg = error.message || error.msg || '保存失败';
					
					// 使用模态框显示错误信息
					uni.showModal({
						title: '保存失败',
						content: errorMsg,
						showCancel: false,
						confirmText: '知道了'
					});
					
					console.error('保存草稿失败:', error);
				}
            }
		}
	}
</script>

<style>
	.add-repair-container {
		min-height: 100vh;
		background-color: #f5f5f7;
		padding-bottom: 120rpx;
	}
	
	.status-bar {
		height: 64rpx;
	}
	
	.navbar {
		display: flex;
		align-items: center;
		justify-content: space-between;
		height: 88rpx;
		background-color: white;
		padding: 0 30rpx;
		border-bottom: 1rpx solid #e5e5e5;
	}
	
	.nav-left {
		width: 60rpx;
		height: 60rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	
	.back-icon {
		font-size: 36rpx;
		color: #333;
	}
	
	.nav-title {
		font-size: 36rpx;
		font-weight: bold;
		color: #333;
	}
	
	.nav-right {
		width: 60rpx;
	}
	
	.form-container {
		padding: 20rpx;
	}
	
	.form-section {
		background-color: white;
		border-radius: 20rpx;
		margin-bottom: 20rpx;
		overflow: hidden;
	}
	
	.section-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 30rpx;
		border-bottom: 1rpx solid #f0f0f0;
	}
	
	.section-title {
		font-size: 32rpx;
		font-weight: bold;
		color: #333;
	}
	
	.form-item {
		padding: 30rpx;
		border-bottom: 1rpx solid #f0f0f0;
	}
	
	.form-item:last-child {
		border-bottom: none;
	}
	
	.form-label {
		display: block;
		font-size: 28rpx;
		color: #333;
		margin-bottom: 20rpx;
	}
	
	.required {
		color: #ff4444;
	}
	
	.form-input {
		width: 100%;
		height: 80rpx;
		font-size: 30rpx;
		color: #333;
		background-color: #f8f9fa;
		border-radius: 10rpx;
		padding: 0 20rpx;
		border: 1rpx solid #e9ecef;
	}
	
	.form-value {
		flex: 1;
		font-size: 28rpx;
		color: #333;
		text-align: right;
	}
	
	.picker-input {
		display: flex;
		justify-content: space-between;
		align-items: center;
		height: 80rpx;
		background-color: #f8f9fa;
		border-radius: 10rpx;
		padding: 0 20rpx;
		border: 1rpx solid #e9ecef;
	}
	
	.picker-text {
		font-size: 30rpx;
		color: #333;
	}
	
	.picker-arrow {
		font-size: 28rpx;
		color: #999;
	}
	
	.picker-input.disabled {
		background-color: #f5f5f5;
		opacity: 0.6;
	}
	
	.picker-input.disabled .picker-text {
		color: #999;
	}
	
	.form-item-column {
		flex-direction: column;
		align-items: stretch;
	}
	
	.image-upload-section {
		width: 100%;
	}
	
	.upload-header {
		display: flex;
		align-items: center;
		gap: 10rpx;
		padding: 20rpx;
		background-color: #f8f9fa;
		border-radius: 10rpx;
		border: 1rpx solid #e9ecef;
	}
	
	.upload-icon {
		font-size: 32rpx;
	}
	
	.upload-text {
		font-size: 28rpx;
		color: #666;
		flex: 1;
	}
	
	.image-count {
		font-size: 24rpx;
		color: #999;
	}
	
	.image-preview-list {
		display: flex;
		flex-wrap: wrap;
		gap: 20rpx;
		margin-top: 20rpx;
	}
	
	.preview-item {
		position: relative;
		width: 160rpx;
		height: 160rpx;
	}
	
	.preview-img {
		width: 100%;
		height: 100%;
		border-radius: 10rpx;
		border: 1rpx solid #e9ecef;
	}
	
	.delete-btn {
		position: absolute;
		top: -10rpx;
		right: -10rpx;
		width: 44rpx;
		height: 44rpx;
		background-color: #ff4444;
		border-radius: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
		box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.2);
	}
	
	.delete-icon {
		font-size: 32rpx;
		color: white;
		line-height: 1;
	}
	
	.form-textarea {
		width: 100%;
		min-height: 200rpx;
		font-size: 30rpx;
		color: #333;
		background-color: #f8f9fa;
		border-radius: 10rpx;
		padding: 20rpx;
		border: 1rpx solid #e9ecef;
	}
	
	.char-count {
		display: block;
		text-align: right;
		font-size: 24rpx;
		color: #999;
		margin-top: 10rpx;
	}
	
	.bottom-actions {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		display: flex;
		background-color: white;
		padding: 20rpx;
		border-top: 1rpx solid #e5e5e5;
	}
	
	.action-button {
		flex: 1;
		height: 80rpx;
		font-size: 32rpx;
		font-weight: bold;
		border-radius: 15rpx;
		border: none;
		margin: 0 10rpx;
	}
	
	.temp-save {
		background-color: white;
		color: #666;
		border: 2rpx solid #e5e5e5;
	}
	
	.submit {
		background-color: #007aff;
		color: white;
	}
	
	.submit-full {
		background-color: #007aff;
		color: white;
		flex: 1;
		margin: 0 10rpx;
	}
	
	/* 资产选择相关样式 */
	.asset-select-wrapper {
		display: flex;
		align-items: center;
		gap: 20rpx;
		background-color: #f8f9fa;
		border-radius: 10rpx;
		padding: 20rpx;
		border: 1rpx solid #e9ecef;
	}
	
	.asset-select-text {
		flex: 1;
		font-size: 30rpx;
		color: #333;
	}
	
	.asset-select-text.placeholder {
		color: #999;
	}
	
	.select-asset-btn {
		background-color: #007aff;
		color: white;
		font-size: 26rpx;
		padding: 10rpx 30rpx;
		border-radius: 8rpx;
		border: none;
		height: auto;
		line-height: normal;
	}
	
	/* 资产选择弹窗 */
	.asset-modal {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background-color: rgba(0, 0, 0, 0.5);
		z-index: 9999;
		display: flex;
		align-items: flex-end;
	}
	
	.modal-content {
		width: 100%;
		max-height: 80vh;
		background-color: white;
		border-radius: 30rpx 30rpx 0 0;
		overflow: hidden;
		display: flex;
		flex-direction: column;
	}
	
	.modal-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 30rpx;
		border-bottom: 1rpx solid #e9ecef;
	}
	
	.modal-title {
		font-size: 32rpx;
		font-weight: bold;
		color: #333;
	}
	
	.modal-close {
		font-size: 48rpx;
		color: #999;
		line-height: 1;
		padding: 0 10rpx;
	}
	
	.modal-search {
		padding: 20rpx 30rpx;
		border-bottom: 1rpx solid #e9ecef;
	}
	
	.search-input {
		width: 100%;
		height: 70rpx;
		background-color: #f8f9fa;
		border-radius: 35rpx;
		padding: 0 30rpx;
		font-size: 28rpx;
		border: 1rpx solid #e9ecef;
	}
	
	.modal-body {
		flex: 1;
		overflow-y: auto;
		padding: 20rpx 30rpx;
	}
	
	.asset-list {
		display: flex;
		flex-direction: column;
		gap: 20rpx;
	}
	
	.asset-item {
		background-color: #f8f9fa;
		border-radius: 10rpx;
		padding: 24rpx;
		border: 1rpx solid #e9ecef;
	}
	
	.asset-info {
		display: flex;
		align-items: center;
		gap: 20rpx;
		margin-bottom: 15rpx;
	}
	
	.asset-no {
		font-size: 28rpx;
		color: #007aff;
		font-weight: bold;
	}
	
	.asset-name {
		font-size: 28rpx;
		color: #333;
		flex: 1;
	}
	
	.asset-detail {
		display: flex;
		gap: 30rpx;
		font-size: 24rpx;
		color: #999;
	}
	
	.asset-location,
	.asset-type {
		display: flex;
		align-items: center;
	}
	
	.empty-data {
		text-align: center;
		padding: 100rpx 0;
	}
	
	.empty-text {
		font-size: 28rpx;
		color: #999;
	}
</style>
